package jm.nj.demo09mian.demo02;

import java.util.HashMap;
import java.util.Hashtable;

/*
 * Mapd 实现类 Hashtable
 * 底层数据结构是哈希表,特点和hashMap是一样的
 * Hashtable 是线程安全集合,运行慢
 * HashMap是线程不安全的集合,运行速度快
 *
 * Hashtable 命运和 Vector 是一样的,从 JDK1.2 开始,被更先进的 HashMap 取代
 *
 * HashMap 允许存储null 值,null键
 * hashtable 不允许存储 null 值,null 健
 *
 * Hashtable 他的子类  Properties依旧活跃在开发舞台
 * */
public class Demo03Hashtaba {
    public static void main(String[] args) {
//HashMap允许存储 null 值,null 健
        HashMap<String,String>map = new HashMap<String, String>();
        map.put("a","1");
        map.put("b","2");
        map.put("c","3");
        map.put("d","4");
        map.put("e","null");
        map.put("null","5");
        map.put("null","null");
        System.out.println(map);

        //hashtable 不允许存储 null 值,null 健
        Hashtable<String,String>table = new Hashtable<String, String>();
        table.put("a","1");
        table.put("b","1");
        table.put("c","1");
        table.put("d","1");
      //  table.put(null,"1");//NullPointerException
     //   table.put("e",null);//NullPointerException
   //     table.put(null,"1");//NullPointerException
     //   table.put(null,null);//NullPointerException
        System.out.println(table);

    }
}
